package com.yang.demo.adapter;

import android.content.Context;
import android.graphics.drawable.GradientDrawable;
import android.support.annotation.NonNull;
import android.support.v4.content.ContextCompat;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import android.widget.Toast;

import com.yang.demo.DataBean;
import com.yang.demo.R;
import com.yang.demo.util.rxbus.RxBus;
import com.yang.demo.view.TagsAdapter;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * Created by moxun on 16/1/19.
 */
public class TextTagsAdapter5 extends TagsAdapter {

    private int colors;

    private Context context;

    public TextTagsAdapter5(Context context, int colors) {
        this.context = context;
        this.colors = colors;
    }

    @Override
    public int getCount() {
        return 15;
    }

    @Override
    public View getView(final Context context, final int position, ViewGroup parent) {
        View view;
        if (position == 1) {
            //指定position=1的view为闪亮的样式
            view = LayoutInflater.from(context).inflate(R.layout.tag_item_view3, parent, false);
            View v = view.findViewById(R.id.view);
            //添加点击事件
            view.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    //如果用户点击的是该view，则通过RxBus通知code=1010的事件打开报告页
                    RxBus.get().send(1010);
                }
            });
        } else {
            //其他view只做展示效果，没有点击事件
            view = LayoutInflater.from(context).inflate(R.layout.tag_item_view4, parent, false);
            View v = view.findViewById(R.id.view);
            GradientDrawable gradientDrawable = (GradientDrawable) v.getBackground();
            gradientDrawable.setColor(ContextCompat.getColor(context, R.color.main_blue));

        }


        return view;
    }

    @Override
    public Object getItem(int position) {
        return position;
    }

    @Override
    public int getPopularity(int position) {
        return position % 7;
    }

    @Override
    public void onThemeColorChanged(View view, int themeColor) {
        view.setBackgroundColor(themeColor);
    }
}